import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import os
import seaborn as sns
from sklearn import linear_model
data_dir = os.getcwd()
tables = {}
for f in list(os.listdir(data_dir)):
if f[-4:] == ".csv":
if pd.read_csv(f, sep=',').shape[1] > pd.read_csv(f, sep=';').shape[1]:
tables[f[:-4]] = pd.read_csv(f, sep=',', names=['time',f[0:-4]])
else:
tables[f[:-4]] = pd.read_csv(f, sep=';', names=['time',f[0:-4]])
tables
{'heat': time heat
0 2015-06-01 02:00:00 910.344750
1 2015-06-01 03:00:00 859.474054
2 2015-06-01 04:00:00 882.489646
3 2015-06-01 05:00:00 932.948964
4 2015-06-01 06:00:00 990.662728
... ... ...
24428 2018-03-16 00:00:00 4983.187094
24429 2018-03-16 01:00:00 4436.284389
24430 2018-03-16 02:00:00 3979.958712
24431 2018-03-16 03:00:00 3621.024717
24432 2018-03-16 04:00:00 3284.236790
[24433 rows x 2 columns],
'HS1_G1': time HS1_G1
0 2014-01-01 05:00:00 16447.303810
1 2014-01-01 06:00:00 16537.577143
2 2014-01-01 07:00:00 16445.183810
3 2014-01-01 08:00:00 16362.103810
4 2014-01-01 09:00:00 15919.877143
... ... ...
36639 2018-03-07 19:00:00 22302.166981
36640 2018-03-07 20:00:00 22152.534491
36641 2018-03-07 21:00:00 22099.938270
36642 2018-03-07 22:00:00 21738.397365
36643 2018-03-07 23:00:00 21385.972811
[36644 rows x 2 columns],
'HS1_G2': time HS1_G2
0 2014-01-01 05:00:00 16399.325036
1 2014-01-01 06:00:00 16480.791703
2 2014-01-01 07:00:00 16406.698370
3 2014-01-01 08:00:00 16285.131703
4 2014-01-01 09:00:00 15984.451703
... ... ...
36639 2018-03-07 19:00:00 22213.226378
36640 2018-03-07 20:00:00 22128.230538
36641 2018-03-07 21:00:00 22081.940284
36642 2018-03-07 22:00:00 21711.974776
36643 2018-03-07 23:00:00 21392.584499
[36644 rows x 2 columns],
'HS1_P1': time HS1_P1
0 2014-01-01 05:00:00 1.279833
1 2014-01-01 06:00:00 1.279560
2 2014-01-01 07:00:00 1.270589
3 2014-01-01 08:00:00 1.241578
4 2014-01-01 09:00:00 1.173625
... ... ...
36639 2018-03-07 19:00:00 1.275033
36640 2018-03-07 20:00:00 1.264490
36641 2018-03-07 21:00:00 1.284467
36642 2018-03-07 22:00:00 1.295712
36643 2018-03-07 23:00:00 1.316906
[36644 rows x 2 columns],
'HS1_P2': time HS1_P2
0 2014-01-01 05:00:00 0.153203
1 2014-01-01 06:00:00 0.153752
2 2014-01-01 07:00:00 0.156398
3 2014-01-01 08:00:00 0.156026
4 2014-01-01 09:00:00 0.183111
... ... ...
36639 2018-03-07 19:00:00 0.093958
36640 2018-03-07 20:00:00 0.087827
36641 2018-03-07 21:00:00 0.112448
36642 2018-03-07 22:00:00 0.099480
36643 2018-03-07 23:00:00 0.089679
[36644 rows x 2 columns],
'HS1_T1': time HS1_T1
0 2014-01-01 05:00:00 84.859847
1 2014-01-01 06:00:00 85.096274
2 2014-01-01 07:00:00 85.401233
3 2014-01-01 08:00:00 83.321207
4 2014-01-01 09:00:00 82.149928
... ... ...
36639 2018-03-07 19:00:00 71.187897
36640 2018-03-07 20:00:00 73.509168
36641 2018-03-07 21:00:00 74.230927
36642 2018-03-07 22:00:00 75.462749
36643 2018-03-07 23:00:00 74.299211
[36644 rows x 2 columns],
'HS1_T2': time HS1_T2
0 2014-01-01 05:00:00 39.317780
1 2014-01-01 06:00:00 39.541879
2 2014-01-01 07:00:00 39.774837
3 2014-01-01 08:00:00 39.888996
4 2014-01-01 09:00:00 39.821501
... ... ...
36639 2018-03-07 19:00:00 34.949755
36640 2018-03-07 20:00:00 34.791563
36641 2018-03-07 21:00:00 34.411225
36642 2018-03-07 22:00:00 34.006612
36643 2018-03-07 23:00:00 33.832444
[36644 rows x 2 columns],
'HS2_G1': time HS2_G1
0 2014-01-01 05:00:00 12171.048344
1 2014-01-01 06:00:00 12218.668968
2 2014-01-01 07:00:00 12226.214704
3 2014-01-01 08:00:00 12144.042325
4 2014-01-01 09:00:00 12464.727244
... ... ...
36639 2018-03-07 19:00:00 16217.418982
36640 2018-03-07 20:00:00 16237.299486
36641 2018-03-07 21:00:00 15903.485110
36642 2018-03-07 22:00:00 16082.627157
36643 2018-03-07 23:00:00 15622.689336
[36644 rows x 2 columns],
'HS2_G2': time HS2_G2
0 2014-01-01 05:00:00 12012.080217
1 2014-01-01 06:00:00 12064.554652
2 2014-01-01 07:00:00 12057.511458
3 2014-01-01 08:00:00 11968.129992
4 2014-01-01 09:00:00 12090.588058
... ... ...
36639 2018-03-07 19:00:00 16342.343188
36640 2018-03-07 20:00:00 16348.541150
36641 2018-03-07 21:00:00 15973.348701
36642 2018-03-07 22:00:00 16155.720478
36643 2018-03-07 23:00:00 15631.594431
[36644 rows x 2 columns],
'HS2_P1': time HS2_P1
0 2014-01-01 05:00:00 1.253798
1 2014-01-01 06:00:00 1.254026
2 2014-01-01 07:00:00 1.253057
3 2014-01-01 08:00:00 1.224238
4 2014-01-01 09:00:00 1.216398
... ... ...
36639 2018-03-07 19:00:00 1.190886
36640 2018-03-07 20:00:00 1.176637
36641 2018-03-07 21:00:00 1.196128
36642 2018-03-07 22:00:00 1.204824
36643 2018-03-07 23:00:00 1.230855
[36644 rows x 2 columns],
'HS2_P2': time HS2_P2
0 2014-01-01 05:00:00 0.110000
1 2014-01-01 06:00:00 0.110214
2 2014-01-01 07:00:00 0.108267
3 2014-01-01 08:00:00 0.105837
4 2014-01-01 09:00:00 0.100881
... ... ...
36639 2018-03-07 19:00:00 0.160329
36640 2018-03-07 20:00:00 0.146311
36641 2018-03-07 21:00:00 0.143989
36642 2018-03-07 22:00:00 0.147072
36643 2018-03-07 23:00:00 0.147736
[36644 rows x 2 columns],
'HS2_T1': time HS2_T1
0 2014-01-01 05:00:00 85.815553
1 2014-01-01 06:00:00 87.129853
2 2014-01-01 07:00:00 87.714275
3 2014-01-01 08:00:00 87.820734
4 2014-01-01 09:00:00 85.944275
... ... ...
36639 2018-03-07 19:00:00 73.047553
36640 2018-03-07 20:00:00 74.525248
36641 2018-03-07 21:00:00 74.794059
36642 2018-03-07 22:00:00 73.703256
36643 2018-03-07 23:00:00 74.967059
[36644 rows x 2 columns],
'HS2_T2': time HS2_T2
0 2014-01-01 05:00:00 38.300996
1 2014-01-01 06:00:00 38.587533
2 2014-01-01 07:00:00 38.801513
3 2014-01-01 08:00:00 38.917598
4 2014-01-01 09:00:00 38.948127
... ... ...
36639 2018-03-07 19:00:00 34.625252
36640 2018-03-07 20:00:00 34.532121
36641 2018-03-07 21:00:00 34.138572
36642 2018-03-07 22:00:00 33.614393
36643 2018-03-07 23:00:00 33.167705
[36644 rows x 2 columns],
'HS3_G1': time HS3_G1
0 2014-01-01 01:00:00 -5.907377
1 2014-01-01 02:00:00 -5.907377
2 2014-01-01 03:00:00 -5.907377
3 2014-01-01 04:00:00 -5.907377
4 2014-01-01 05:00:00 -5.907377
... ... ...
36643 2018-03-07 19:00:00 -5.907377
36644 2018-03-07 20:00:00 -5.907377
36645 2018-03-07 21:00:00 -5.907377
36646 2018-03-07 22:00:00 -5.907377
36647 2018-03-07 23:00:00 -5.907377
[36648 rows x 2 columns],
'node1_T1': time node1_T1
0 2015-06-01 01:00:00 60.383622
1 2015-06-01 02:00:00 57.071122
2 2015-06-01 03:00:00 57.871122
3 2015-06-01 04:00:00 58.533623
4 2015-06-01 05:00:00 59.246124
... ... ...
24682 2018-03-26 01:00:00 73.246793
24683 2018-03-26 02:00:00 73.255954
24684 2018-03-26 03:00:00 73.265114
24685 2018-03-26 04:00:00 73.274275
24686 2018-03-26 05:00:00 73.283435
[24687 rows x 2 columns],
'node2_T1': time node2_T1
0 2015-06-01 01:00:00 57.267636
1 2015-06-01 02:00:00 56.596221
2 2015-06-01 03:00:00 56.611903
3 2015-06-01 04:00:00 57.053826
4 2015-06-01 05:00:00 57.443008
... ... ...
24663 2018-03-26 01:00:00 70.508907
24664 2018-03-26 02:00:00 70.464022
24665 2018-03-26 03:00:00 70.419136
24666 2018-03-26 04:00:00 70.374251
24667 2018-03-26 05:00:00 70.329365
[24668 rows x 2 columns],
'node3_T1': time node3_T1
0 2015-06-01 01:00:00 57.683892
1 2015-06-01 02:00:00 57.025654
2 2015-06-01 03:00:00 57.027647
3 2015-06-01 04:00:00 57.470921
4 2015-06-01 05:00:00 57.424246
... ... ...
24682 2018-03-26 01:00:00 71.071906
24683 2018-03-26 02:00:00 70.948555
24684 2018-03-26 03:00:00 70.825205
24685 2018-03-26 04:00:00 70.701855
24686 2018-03-26 05:00:00 70.578505
[24687 rows x 2 columns]}
for key,df in tables.items():
df['time'] = pd.to_datetime(df['time'], format='%Y-%m-%d %H:%M:%S')
df.index = df['time']
df.drop('time',axis=1,inplace=True)
data = pd.DataFrame()
for key,df in tables.items():
df = df.groupby(df.index).first()
data = data.join(df, how='outer')
print(key, df.shape, data.shape)
heat (24433, 1) (24433, 1) HS1_G1 (36643, 1) (36840, 2) HS1_G2 (36643, 1) (36840, 3) HS1_P1 (36643, 1) (36840, 4) HS1_P2 (36643, 1) (36840, 5) HS1_T1 (36643, 1) (36840, 6) HS1_T2 (36643, 1) (36840, 7) HS2_G1 (36643, 1) (36840, 8) HS2_G2 (36643, 1) (36840, 9) HS2_P1 (36643, 1) (36840, 10) HS2_P2 (36643, 1) (36840, 11) HS2_T1 (36643, 1) (36840, 12) HS2_T2 (36643, 1) (36840, 13) HS3_G1 (36647, 1) (36844, 14) node1_T1 (24687, 1) (37084, 15) node2_T1 (24668, 1) (37084, 16) node3_T1 (24687, 1) (37084, 17)
data.plot(subplots=True, figsize=(20,20))
plt.show()
sub1 = data.copy()
sub1 = sub1.dropna(axis=0, how='any')
plt.figure(figsize=(20,10));
sub1['node1_T1'].plot();
plt.legend(loc='upper left');
plt.twinx();
sub1['HS1_T1'].plot(color='tab:red');
plt.legend();
plt.show();
plt.figure(figsize=(20,10));
sub1['node1_T1'].plot();
plt.legend(loc='upper left');
plt.twinx();
sub1['heat'].plot(color='tab:red');
plt.legend();
plt.show();
plt.figure(figsize=(20,10))
plt.scatter(sub1['HS1_T1'],sub1['node1_T1'], alpha=0.1);
plt.xlabel('HS1_T1 [°C]');
plt.ylabel('node1_T1 [°C]');
plt.figure(figsize=(20,10))
plt.scatter(sub1['heat'],sub1['node1_T1'], alpha=0.1);
plt.xlabel('heat');
plt.ylabel('node1_T1 [°C]');
plt.figure(figsize=(20,10));
sub1.loc[sub1['HS3_G1']<100, 'HS3_G1'].hist(bins=40);
#Filtering for all values of when HS3 is off:
sub1 = sub1[sub1['HS3_G1'] <= 0]
sub1.plot(subplots=True, figsize=(20,20));
#filtering for notorious outliers
sub1 = sub1[(sub1['node1_T1'] < 100) & (sub1['node1_T1'] > 50)]
sub1 = sub1[(sub1['HS1_T1'] < 100) & (sub1['HS1_T1'] > 50)]
plt.figure(figsize=(20,10));
sub1['node1_T1'].plot();
plt.legend(loc='upper left');
plt.twinx();
sub1['HS1_T1'].plot(color='tab:red');
plt.grid();
plt.legend();
plt.show();
#separating datasets by winter and summer sessions using temperature of substation
sub1_summer = sub1[(sub1['node1_T1'] <= 65)]
sub1_winter = sub1[sub1['node1_T1'] > 65]
plt.figure(figsize=(20,10))
plt.scatter(sub1_summer['HS1_T1'],sub1_summer['node1_T1']);
plt.xlabel('HS1_T1 [°C]');
plt.ylabel('node1_T1 [°C]');
plt.title('Summer data');
plt.figure(figsize=(20,10))
plt.scatter(sub1_winter['HS1_T1'],sub1_winter['node1_T1']);
plt.xlabel('HS1_T1 [°C]');
plt.ylabel('node1_T1 [°C]');
plt.title('Winter data');
#separating datasets by winter and summer sessions using heat
sub2_summer = sub1[(sub1['heat'] <= 1500)]
sub2_winter = sub1[sub1['heat'] > 1500]
plt.figure(figsize=(20,10))
plt.scatter(sub2_summer['heat'],sub2_summer['node1_T1']);
plt.xlabel('heat');
plt.ylabel('node1_T1 [°C]');
plt.title('Summer data');
plt.figure(figsize=(20,10))
plt.scatter(sub2_winter['heat'],sub2_winter['node1_T1']);
plt.xlabel('heat');
plt.ylabel('node1_T1 [°C]');
plt.title('Winter data');
sub1 = sub1.drop(columns=['HS3_G1'])
corr_matrix = sub1.corr()
corr_matrix
| heat | HS1_G1 | HS1_G2 | HS1_P1 | HS1_P2 | HS1_T1 | HS1_T2 | HS2_G1 | HS2_G2 | HS2_P1 | HS2_P2 | HS2_T1 | HS2_T2 | node1_T1 | node2_T1 | node3_T1 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| heat | 1.000000 | 0.960797 | 0.953875 | 0.943055 | 0.244104 | 0.704986 | 0.095525 | 0.958722 | 0.954627 | 0.908428 | -0.100726 | 0.590439 | 0.160937 | 0.878339 | 0.880695 | 0.902663 |
| HS1_G1 | 0.960797 | 1.000000 | 0.989798 | 0.952424 | 0.254601 | 0.556203 | -0.011953 | 0.990228 | 0.985035 | 0.909057 | -0.060110 | 0.452335 | 0.061017 | 0.781149 | 0.759977 | 0.794674 |
| HS1_G2 | 0.953875 | 0.989798 | 1.000000 | 0.944865 | 0.264592 | 0.556155 | -0.037799 | 0.981443 | 0.977160 | 0.904860 | -0.073680 | 0.459506 | 0.049074 | 0.783919 | 0.757284 | 0.794318 |
| HS1_P1 | 0.943055 | 0.952424 | 0.944865 | 1.000000 | 0.220682 | 0.605100 | 0.012612 | 0.958944 | 0.960371 | 0.957010 | -0.082933 | 0.498560 | 0.082098 | 0.795580 | 0.781822 | 0.807326 |
| HS1_P2 | 0.244104 | 0.254601 | 0.264592 | 0.220682 | 1.000000 | 0.054556 | -0.130933 | 0.266163 | 0.251289 | 0.274556 | -0.041633 | 0.143070 | -0.117365 | 0.234040 | 0.133375 | 0.182377 |
| HS1_T1 | 0.704986 | 0.556203 | 0.556155 | 0.605100 | 0.054556 | 1.000000 | 0.430982 | 0.556627 | 0.559347 | 0.579855 | -0.072654 | 0.777856 | 0.429918 | 0.795496 | 0.842283 | 0.816084 |
| HS1_T2 | 0.095525 | -0.011953 | -0.037799 | 0.012612 | -0.130933 | 0.430982 | 1.000000 | -0.009588 | -0.002038 | -0.002965 | 0.101846 | 0.344373 | 0.567376 | 0.223751 | 0.283077 | 0.248142 |
| HS2_G1 | 0.958722 | 0.990228 | 0.981443 | 0.958944 | 0.266163 | 0.556627 | -0.009588 | 1.000000 | 0.996509 | 0.921377 | -0.059007 | 0.450847 | 0.067561 | 0.777257 | 0.760852 | 0.791888 |
| HS2_G2 | 0.954627 | 0.985035 | 0.977160 | 0.960371 | 0.251289 | 0.559347 | -0.002038 | 0.996509 | 1.000000 | 0.918269 | -0.041831 | 0.449432 | 0.071809 | 0.772696 | 0.758475 | 0.788147 |
| HS2_P1 | 0.908428 | 0.909057 | 0.904860 | 0.957010 | 0.274556 | 0.579855 | -0.002965 | 0.921377 | 0.918269 | 1.000000 | -0.005416 | 0.603950 | 0.220075 | 0.780501 | 0.754489 | 0.782670 |
| HS2_P2 | -0.100726 | -0.060110 | -0.073680 | -0.082933 | -0.041633 | -0.072654 | 0.101846 | -0.059007 | -0.041831 | -0.005416 | 1.000000 | 0.103549 | 0.358805 | -0.178245 | -0.125895 | -0.142415 |
| HS2_T1 | 0.590439 | 0.452335 | 0.459506 | 0.498560 | 0.143070 | 0.777856 | 0.344373 | 0.450847 | 0.449432 | 0.603950 | 0.103549 | 1.000000 | 0.628371 | 0.705557 | 0.705380 | 0.695996 |
| HS2_T2 | 0.160937 | 0.061017 | 0.049074 | 0.082098 | -0.117365 | 0.429918 | 0.567376 | 0.067561 | 0.071809 | 0.220075 | 0.358805 | 0.628371 | 1.000000 | 0.273389 | 0.334134 | 0.296561 |
| node1_T1 | 0.878339 | 0.781149 | 0.783919 | 0.795580 | 0.234040 | 0.795496 | 0.223751 | 0.777257 | 0.772696 | 0.780501 | -0.178245 | 0.705557 | 0.273389 | 1.000000 | 0.897508 | 0.902144 |
| node2_T1 | 0.880695 | 0.759977 | 0.757284 | 0.781822 | 0.133375 | 0.842283 | 0.283077 | 0.760852 | 0.758475 | 0.754489 | -0.125895 | 0.705380 | 0.334134 | 0.897508 | 1.000000 | 0.955693 |
| node3_T1 | 0.902663 | 0.794674 | 0.794318 | 0.807326 | 0.182377 | 0.816084 | 0.248142 | 0.791888 | 0.788147 | 0.782670 | -0.142415 | 0.695996 | 0.296561 | 0.902144 | 0.955693 | 1.000000 |
plt.figure(figsize=(20,10))
sns.heatmap(corr_matrix, xticklabels=corr_matrix.columns, yticklabels=corr_matrix.columns,cmap='RdBu_r',
annot=True,linewidth=0.5);
for Delay in range(1,24):
sub1["HS1_T1_del_"+str(Delay)]=pd.concat(
[pd.DataFrame([{sub1[["HS1_T1"]].columns[0]: np.nan} for i in range(0,Delay)]),
sub1[["HS1_T1"]]], axis = 0).drop(sub1["HS1_T1"].tail(Delay).index).values
corr_matrix_del = sub1.corr()
corr_matrix_del
| heat | HS1_G1 | HS1_G2 | HS1_P1 | HS1_P2 | HS1_T1 | HS1_T2 | HS2_G1 | HS2_G2 | HS2_P1 | ... | HS1_T1_del_14 | HS1_T1_del_15 | HS1_T1_del_16 | HS1_T1_del_17 | HS1_T1_del_18 | HS1_T1_del_19 | HS1_T1_del_20 | HS1_T1_del_21 | HS1_T1_del_22 | HS1_T1_del_23 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| heat | 1.000000 | 0.960797 | 0.953875 | 0.943055 | 0.244104 | 0.704986 | 0.095525 | 0.958722 | 0.954627 | 0.908428 | ... | 0.695291 | 0.693526 | 0.691637 | 0.689639 | 0.687175 | 0.684678 | 0.681914 | 0.679374 | 0.677084 | 0.674901 |
| HS1_G1 | 0.960797 | 1.000000 | 0.989798 | 0.952424 | 0.254601 | 0.556203 | -0.011953 | 0.990228 | 0.985035 | 0.909057 | ... | 0.573501 | 0.575014 | 0.575913 | 0.576596 | 0.576781 | 0.576699 | 0.576305 | 0.575519 | 0.573994 | 0.572168 |
| HS1_G2 | 0.953875 | 0.989798 | 1.000000 | 0.944865 | 0.264592 | 0.556155 | -0.037799 | 0.981443 | 0.977160 | 0.904860 | ... | 0.570060 | 0.571495 | 0.572326 | 0.572876 | 0.572996 | 0.572750 | 0.572317 | 0.571518 | 0.570281 | 0.568838 |
| HS1_P1 | 0.943055 | 0.952424 | 0.944865 | 1.000000 | 0.220682 | 0.605100 | 0.012612 | 0.958944 | 0.960371 | 0.957010 | ... | 0.583557 | 0.584474 | 0.585365 | 0.586399 | 0.587359 | 0.588288 | 0.588893 | 0.589262 | 0.589122 | 0.588664 |
| HS1_P2 | 0.244104 | 0.254601 | 0.264592 | 0.220682 | 1.000000 | 0.054556 | -0.130933 | 0.266163 | 0.251289 | 0.274556 | ... | 0.035301 | 0.033446 | 0.032796 | 0.034029 | 0.036194 | 0.036857 | 0.037862 | 0.039201 | 0.041190 | 0.041992 |
| HS1_T1 | 0.704986 | 0.556203 | 0.556155 | 0.605100 | 0.054556 | 1.000000 | 0.430982 | 0.556627 | 0.559347 | 0.579855 | ... | 0.731307 | 0.728002 | 0.726262 | 0.725443 | 0.726837 | 0.728876 | 0.731950 | 0.734278 | 0.735628 | 0.735721 |
| HS1_T2 | 0.095525 | -0.011953 | -0.037799 | 0.012612 | -0.130933 | 0.430982 | 1.000000 | -0.009588 | -0.002038 | -0.002965 | ... | 0.300133 | 0.294547 | 0.290361 | 0.288537 | 0.290451 | 0.294276 | 0.304664 | 0.314723 | 0.321558 | 0.317244 |
| HS2_G1 | 0.958722 | 0.990228 | 0.981443 | 0.958944 | 0.266163 | 0.556627 | -0.009588 | 1.000000 | 0.996509 | 0.921377 | ... | 0.573577 | 0.574970 | 0.576026 | 0.576829 | 0.577094 | 0.576921 | 0.576470 | 0.575608 | 0.574051 | 0.572172 |
| HS2_G2 | 0.954627 | 0.985035 | 0.977160 | 0.960371 | 0.251289 | 0.559347 | -0.002038 | 0.996509 | 1.000000 | 0.918269 | ... | 0.573061 | 0.574445 | 0.575523 | 0.576421 | 0.576755 | 0.576628 | 0.576223 | 0.575400 | 0.573931 | 0.572156 |
| HS2_P1 | 0.908428 | 0.909057 | 0.904860 | 0.957010 | 0.274556 | 0.579855 | -0.002965 | 0.921377 | 0.918269 | 1.000000 | ... | 0.553682 | 0.554379 | 0.555485 | 0.556637 | 0.557455 | 0.558224 | 0.558996 | 0.559859 | 0.560293 | 0.560460 |
| HS2_P2 | -0.100726 | -0.060110 | -0.073680 | -0.082933 | -0.041633 | -0.072654 | 0.101846 | -0.059007 | -0.041831 | -0.005416 | ... | -0.065993 | -0.063313 | -0.061208 | -0.058442 | -0.056767 | -0.054795 | -0.053091 | -0.052932 | -0.053334 | -0.053826 |
| HS2_T1 | 0.590439 | 0.452335 | 0.459506 | 0.498560 | 0.143070 | 0.777856 | 0.344373 | 0.450847 | 0.449432 | 0.603950 | ... | 0.607484 | 0.605781 | 0.605003 | 0.604372 | 0.603766 | 0.604669 | 0.606911 | 0.609379 | 0.611739 | 0.613050 |
| HS2_T2 | 0.160937 | 0.061017 | 0.049074 | 0.082098 | -0.117365 | 0.429918 | 0.567376 | 0.067561 | 0.071809 | 0.220075 | ... | 0.312718 | 0.307505 | 0.305134 | 0.305150 | 0.306306 | 0.310122 | 0.316422 | 0.323929 | 0.330873 | 0.336998 |
| node1_T1 | 0.878339 | 0.781149 | 0.783919 | 0.795580 | 0.234040 | 0.795496 | 0.223751 | 0.777257 | 0.772696 | 0.780501 | ... | 0.702598 | 0.696816 | 0.692152 | 0.688720 | 0.686568 | 0.685021 | 0.683998 | 0.684066 | 0.685197 | 0.685738 |
| node2_T1 | 0.880695 | 0.759977 | 0.757284 | 0.781822 | 0.133375 | 0.842283 | 0.283077 | 0.760852 | 0.758475 | 0.754489 | ... | 0.793696 | 0.783238 | 0.774161 | 0.766256 | 0.760740 | 0.756185 | 0.752067 | 0.749183 | 0.747040 | 0.745286 |
| node3_T1 | 0.902663 | 0.794674 | 0.794318 | 0.807326 | 0.182377 | 0.816084 | 0.248142 | 0.791888 | 0.788147 | 0.782670 | ... | 0.813901 | 0.803405 | 0.794072 | 0.785362 | 0.777995 | 0.772315 | 0.767933 | 0.764668 | 0.761694 | 0.758865 |
| HS1_T1_del_1 | 0.702699 | 0.551400 | 0.551740 | 0.600765 | 0.043756 | 0.959984 | 0.435491 | 0.552549 | 0.554703 | 0.576468 | ... | 0.736743 | 0.731295 | 0.727996 | 0.726269 | 0.725468 | 0.726868 | 0.728896 | 0.731959 | 0.734280 | 0.735625 |
| HS1_T1_del_2 | 0.702810 | 0.548297 | 0.548604 | 0.597112 | 0.035382 | 0.922489 | 0.432600 | 0.550145 | 0.551683 | 0.573363 | ... | 0.743967 | 0.736726 | 0.731278 | 0.727987 | 0.726273 | 0.725477 | 0.726868 | 0.728888 | 0.731945 | 0.734264 |
| HS1_T1_del_3 | 0.704861 | 0.547237 | 0.547190 | 0.593498 | 0.032781 | 0.895237 | 0.425412 | 0.548838 | 0.549905 | 0.569905 | ... | 0.752655 | 0.743956 | 0.736722 | 0.731286 | 0.728014 | 0.726306 | 0.725498 | 0.726878 | 0.728889 | 0.731943 |
| HS1_T1_del_4 | 0.706467 | 0.548021 | 0.547649 | 0.590274 | 0.032503 | 0.871227 | 0.421766 | 0.549052 | 0.549739 | 0.566695 | ... | 0.764110 | 0.752649 | 0.743961 | 0.736742 | 0.731328 | 0.728061 | 0.726340 | 0.725519 | 0.726889 | 0.728896 |
| HS1_T1_del_5 | 0.707158 | 0.549770 | 0.549160 | 0.587619 | 0.031932 | 0.849577 | 0.415043 | 0.550228 | 0.550625 | 0.563721 | ... | 0.775617 | 0.764124 | 0.752686 | 0.744023 | 0.736834 | 0.731429 | 0.728144 | 0.726402 | 0.725567 | 0.726929 |
| HS1_T1_del_6 | 0.706838 | 0.552182 | 0.551250 | 0.585225 | 0.032381 | 0.828432 | 0.405413 | 0.552312 | 0.552426 | 0.560751 | ... | 0.789437 | 0.775652 | 0.764192 | 0.752788 | 0.744161 | 0.736983 | 0.731554 | 0.728245 | 0.726485 | 0.725638 |
| HS1_T1_del_7 | 0.705548 | 0.554782 | 0.553434 | 0.583257 | 0.033448 | 0.807396 | 0.391223 | 0.554739 | 0.554579 | 0.557918 | ... | 0.807509 | 0.789496 | 0.775753 | 0.764334 | 0.752974 | 0.744359 | 0.737154 | 0.731696 | 0.728364 | 0.726590 |
| HS1_T1_del_8 | 0.704217 | 0.557509 | 0.556002 | 0.582135 | 0.034087 | 0.789368 | 0.378066 | 0.557372 | 0.557068 | 0.556034 | ... | 0.828580 | 0.807554 | 0.789578 | 0.775872 | 0.764493 | 0.753143 | 0.744503 | 0.737271 | 0.731792 | 0.728447 |
| HS1_T1_del_9 | 0.702794 | 0.560425 | 0.558644 | 0.581437 | 0.033849 | 0.775584 | 0.364642 | 0.560326 | 0.559942 | 0.554293 | ... | 0.849730 | 0.828620 | 0.807630 | 0.789690 | 0.776023 | 0.764653 | 0.753278 | 0.744612 | 0.737360 | 0.731868 |
| HS1_T1_del_10 | 0.701283 | 0.563412 | 0.561386 | 0.581218 | 0.034064 | 0.764107 | 0.350830 | 0.563506 | 0.563059 | 0.553186 | ... | 0.871361 | 0.849771 | 0.828697 | 0.807743 | 0.789842 | 0.776184 | 0.764790 | 0.753388 | 0.744701 | 0.737436 |
| HS1_T1_del_11 | 0.699740 | 0.566454 | 0.564126 | 0.581441 | 0.034076 | 0.752662 | 0.336806 | 0.566489 | 0.566035 | 0.552871 | ... | 0.895326 | 0.871383 | 0.849823 | 0.828779 | 0.807858 | 0.789964 | 0.776284 | 0.764866 | 0.753446 | 0.744749 |
| HS1_T1_del_12 | 0.698391 | 0.569106 | 0.566281 | 0.582010 | 0.034727 | 0.743979 | 0.324124 | 0.569198 | 0.568762 | 0.552705 | ... | 0.922532 | 0.895342 | 0.871426 | 0.849893 | 0.828880 | 0.807966 | 0.790049 | 0.776347 | 0.764913 | 0.753483 |
| HS1_T1_del_13 | 0.696902 | 0.571510 | 0.568288 | 0.582720 | 0.035293 | 0.736752 | 0.310168 | 0.571647 | 0.571175 | 0.553167 | ... | 0.959996 | 0.922543 | 0.895376 | 0.871485 | 0.849982 | 0.828975 | 0.808038 | 0.790100 | 0.776383 | 0.764939 |
| HS1_T1_del_14 | 0.695291 | 0.573501 | 0.570060 | 0.583557 | 0.035301 | 0.731307 | 0.300133 | 0.573577 | 0.573061 | 0.553682 | ... | 1.000000 | 0.960000 | 0.922562 | 0.895415 | 0.871548 | 0.850049 | 0.829022 | 0.808067 | 0.790115 | 0.776390 |
| HS1_T1_del_15 | 0.693526 | 0.575014 | 0.571495 | 0.584474 | 0.033446 | 0.728002 | 0.294547 | 0.574970 | 0.574445 | 0.554379 | ... | 0.960000 | 1.000000 | 0.960003 | 0.922573 | 0.895440 | 0.871574 | 0.850059 | 0.829019 | 0.808054 | 0.790098 |
| HS1_T1_del_16 | 0.691637 | 0.575913 | 0.572326 | 0.585365 | 0.032796 | 0.726262 | 0.290361 | 0.576026 | 0.575523 | 0.555485 | ... | 0.922562 | 0.960003 | 1.000000 | 0.959999 | 0.922570 | 0.895434 | 0.871556 | 0.850033 | 0.828988 | 0.808021 |
| HS1_T1_del_17 | 0.689639 | 0.576596 | 0.572876 | 0.586399 | 0.034029 | 0.725443 | 0.288537 | 0.576829 | 0.576421 | 0.556637 | ... | 0.895415 | 0.922573 | 0.959999 | 1.000000 | 0.959991 | 0.922553 | 0.895406 | 0.871523 | 0.849999 | 0.828954 |
| HS1_T1_del_18 | 0.687175 | 0.576781 | 0.572996 | 0.587359 | 0.036194 | 0.726837 | 0.290451 | 0.577094 | 0.576755 | 0.557455 | ... | 0.871548 | 0.895440 | 0.922570 | 0.959991 | 1.000000 | 0.959977 | 0.922527 | 0.895378 | 0.871496 | 0.849973 |
| HS1_T1_del_19 | 0.684678 | 0.576699 | 0.572750 | 0.588288 | 0.036857 | 0.728876 | 0.294276 | 0.576921 | 0.576628 | 0.558224 | ... | 0.850049 | 0.871574 | 0.895434 | 0.922553 | 0.959977 | 1.000000 | 0.959964 | 0.922508 | 0.895359 | 0.871478 |
| HS1_T1_del_20 | 0.681914 | 0.576305 | 0.572317 | 0.588893 | 0.037862 | 0.731950 | 0.304664 | 0.576470 | 0.576223 | 0.558996 | ... | 0.829022 | 0.850059 | 0.871556 | 0.895406 | 0.922527 | 0.959964 | 1.000000 | 0.959954 | 0.922493 | 0.895343 |
| HS1_T1_del_21 | 0.679374 | 0.575519 | 0.571518 | 0.589262 | 0.039201 | 0.734278 | 0.314723 | 0.575608 | 0.575400 | 0.559859 | ... | 0.808067 | 0.829019 | 0.850033 | 0.871523 | 0.895378 | 0.922508 | 0.959954 | 1.000000 | 0.959946 | 0.922479 |
| HS1_T1_del_22 | 0.677084 | 0.573994 | 0.570281 | 0.589122 | 0.041190 | 0.735628 | 0.321558 | 0.574051 | 0.573931 | 0.560293 | ... | 0.790115 | 0.808054 | 0.828988 | 0.849999 | 0.871496 | 0.895359 | 0.922493 | 0.959946 | 1.000000 | 0.959938 |
| HS1_T1_del_23 | 0.674901 | 0.572168 | 0.568838 | 0.588664 | 0.041992 | 0.735721 | 0.317244 | 0.572172 | 0.572156 | 0.560460 | ... | 0.776390 | 0.790098 | 0.808021 | 0.828954 | 0.849973 | 0.871478 | 0.895343 | 0.922479 | 0.959938 | 1.000000 |
39 rows × 39 columns
plt.figure(figsize=(20,10))
sns.heatmap(corr_matrix_del, xticklabels=corr_matrix_del.columns, yticklabels=corr_matrix_del.columns,cmap='RdBu_r',
annot=True,linewidth=0.5);
plt.figure(figsize=(20,10))
plt.bar(sub1.columns[16:], sub1.corr()['node1_T1'].values[16:]);
plt.xticks(rotation=45);
plt.plot();
sub1_summer = sub1[sub1['node1_T1'] <= 65]
sub1_winter = sub1[sub1['node1_T1'] > 65]
plt.figure(figsize=(20,10))
plt.scatter(sub1_summer['HS1_T1'],sub1_summer['node1_T1']);
plt.xlabel('HS1_T1 [°C]');
plt.ylabel('node1_T1 [°C]');
plt.title('Summer data');
plt.figure(figsize=(20,10))
plt.scatter(sub1_winter['HS1_T1_del_4'],sub1_winter['node1_T1']);
plt.xlabel('HS1_T1_del_4 [°C]');
plt.ylabel('node1_T1 [°C]');
plt.title('Winter data');
#Evaluation of summer model with temperature as input
reg_summer = linear_model.LinearRegression()
reg_summer.fit(sub1_summer['HS1_T1'].values.reshape(-1,1), sub1_summer['node1_T1'])
LinearRegression()
reg_summer.score(sub1_summer['HS1_T1'].values.reshape(-1,1), sub1_summer['node1_T1'])
0.019941577993297877
y_pred_summer = reg_summer.predict(sub1_summer['HS1_T1'].values.reshape(-1,1))
plt.figure(figsize=(20,10))
plt.scatter(sub1_summer['HS1_T1'],sub1_summer['node1_T1'], label='Actual data');
plt.plot(sub1_summer['HS1_T1'], y_pred_summer, color='tab:green', label='Linear regression');
plt.xlabel('HS1_T1 [°C]');
plt.ylabel('node1_T1 [°C]');
plt.legend();
plt.title('Summer data');
#Evaluation of summer model with heat as imput
reg_summer2 = linear_model.LinearRegression()
reg_summer2.fit(sub2_summer['heat'].values.reshape(-1,1), sub2_summer['node1_T1'])
LinearRegression()
reg_summer2.score(sub2_summer['heat'].values.reshape(-1,1), sub2_summer['node1_T1'])
0.0924755483348898
y_pred_summer2 = reg_summer2.predict(sub2_summer['heat'].values.reshape(-1,1))
plt.figure(figsize=(20,10))
plt.scatter(sub2_summer['heat'],sub2_summer['node1_T1'], label='Actual data');
plt.plot(sub2_summer['heat'], y_pred_summer2, color='tab:green', label='Linear regression');
plt.xlabel('heat');
plt.ylabel('node1_T1 [°C]');
plt.legend();
plt.title('Summer data');
#Evaluation of winter model with temperature as imput
reg_winter = linear_model.LinearRegression()
reg_winter.fit(sub1_winter['HS1_T1_del_4'].values.reshape(-1,1), sub1_winter['node1_T1'])
LinearRegression()
reg_winter.score(sub1_winter['HS1_T1_del_4'].values.reshape(-1,1), sub1_winter['node1_T1'])
0.651427646808568
y_pred_winter = reg_winter.predict(sub1_winter['HS1_T1_del_4'].values.reshape(-1,1))
plt.figure(figsize=(20,10))
plt.scatter(sub1_winter['HS1_T1_del_4'],sub1_winter['node1_T1'], label='Actual data');
plt.plot(sub1_winter['HS1_T1_del_4'], y_pred_winter, color='tab:green', label='Linear regression')
plt.xlabel('HS1_T1_del_4 [°C]');
plt.ylabel('node1_T1 [°C]');
plt.legend();
plt.title('Winter data');
#Evaluation of winter model with heat as imput
reg_winter2 = linear_model.LinearRegression()
reg_winter2.fit(sub2_winter['heat'].values.reshape(-1,1), sub2_winter['node1_T1'])
LinearRegression()
reg_winter2.score(sub2_winter['heat'].values.reshape(-1,1), sub2_winter['node1_T1'])
0.5401711146717058
y_pred_winter2 = reg_winter2.predict(sub2_winter['heat'].values.reshape(-1,1))
plt.figure(figsize=(20,10))
plt.scatter(sub2_winter['heat'],sub2_winter['node1_T1'], label='Actual data');
plt.plot(sub2_winter['heat'], y_pred_winter2, color='tab:green', label='Linear regression');
plt.xlabel('heat');
plt.ylabel('node1_T1 [°C]');
plt.legend();
plt.title('Winter data');
#Correlation matrix for summer to find additional inputs
corr_matrix_summer = sub1_summer.corr()
plt.figure(figsize=(20,10))
sns.heatmap(corr_matrix_summer, xticklabels=corr_matrix_summer.columns, yticklabels=corr_matrix_summer.columns,
cmap='RdBu_r', annot=True,linewidth=0.5);
#Increase of summer model quality by adding better-suited parameters
reg_summer_1 = linear_model.LinearRegression()
reg_summer_1.fit(sub1_summer[['heat','HS1_T1','HS1_G2','HS2_G1']], sub1_summer['node1_T1'])
LinearRegression()
reg_summer_1.score(sub1_summer[['heat','HS1_T1','HS1_G2','HS2_G1']], sub1_summer['node1_T1'])
0.4664206583169196
reg_summer_1.coef_
array([ 0.00219089, 0.09158439, 0.00013776, -0.00035828])
reg_summer_1.intercept_
51.50364601630728
y = 51.50364601630728 + 0.00219089(heat) + 0.09158439(HS1_T1) + 0.00013776(HS1_G2) - 0.00035828(HS2_G1)
corr_matrix_summer2 = sub2_summer.corr()
plt.figure(figsize=(20,10))
sns.heatmap(corr_matrix_summer2, xticklabels=corr_matrix_summer2.columns, yticklabels=corr_matrix_summer2.columns,
cmap='RdBu_r', annot=True,linewidth=0.5);
#Analysis for the summer model when filtered by heat
reg_summer_2 = linear_model.LinearRegression()
reg_summer_2.fit(sub2_summer[['heat','HS2_T1','HS1_G2','HS1_G1']], sub2_summer['node1_T1'])
LinearRegression()
reg_summer_2.score(sub2_summer[['heat','HS2_T1','HS1_G2','HS1_G1']], sub2_summer['node1_T1'])
0.16139087990576895
reg_summer_2.coef_
array([ 0.00338078, 0.08888249, 0.00026093, -0.0002713 ])
reg_summer_2.intercept_
50.42344013295554
y = 50.42344013295554 + 0.00338078(heat) + 0.08888249(HS2_T1) + 0.00026093(HS1_G2) - 0.0002713(HS1_G1)
corr_matrix_winter = sub1_winter.corr()
plt.figure(figsize=(20,10))
sns.heatmap(corr_matrix_winter, xticklabels=corr_matrix_winter.columns, yticklabels=corr_matrix_winter.columns,
cmap='RdBu_r', annot=True,linewidth=0.5);
#Increase of winter model quality by adding more inputs
reg_winter_1 = linear_model.LinearRegression()
reg_winter_1.fit(sub1_winter[['heat','HS1_T1_del_4','HS1_T2','HS2_T1']], sub1_winter['node1_T1'])
LinearRegression()
reg_winter_1.score(sub1_winter[['heat','HS1_T1_del_4','HS1_T2','HS2_T1']], sub1_winter['node1_T1'])
0.7182154603794073
reg_winter_1.coef_
array([3.81579495e-04, 3.26788154e-01, 4.88086021e-01, 1.43602310e-01])
reg_winter_1.intercept_
18.769292785207163
y = 18.769292785207163 + 3.81579495e-04(heat) + 3.26788154e-01(HS1_T1_del_4) + 4.88086021e-01(HS1_T2) + 1.43602310e-01(HS2_T1)
corr_matrix_winter2 = sub2_winter.corr()
plt.figure(figsize=(20,10))
sns.heatmap(corr_matrix_winter2, xticklabels=corr_matrix_winter2.columns, yticklabels=corr_matrix_winter2.columns,
cmap='RdBu_r', annot=True,linewidth=0.5);
#Analysis of winter model when filtered by heat
reg_winter_2 = linear_model.LinearRegression()
reg_winter_2.fit(sub2_winter[['heat','HS1_T1_del_4','HS1_T2','HS2_T1']], sub2_winter['node1_T1'])
LinearRegression()
reg_winter_2.score(sub2_winter[['heat','HS1_T1_del_4','HS1_T2','HS2_T1']], sub2_winter['node1_T1'])
0.7550210121968939
reg_winter_2.coef_
array([0.00106214, 0.37738452, 0.48895896, 0.14020258])
reg_winter_2.intercept_
11.718470378984144
y = 11.718470378984144 + 0.00106214(heat) + 0.37738452(HS1_T1_del_4) + 0.48895896(HS1_T2) + 0.14020258(HS2_T1)